package com.shop.controller;

import com.shop.common.ResponseResult;
import com.shop.service.RightsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
public class RightController {
    @Autowired
    private RightsService rightsService;
    @GetMapping("rights/{type}")
    public ResponseResult selectRights(@PathVariable String type){
        if (type.equals("list")){
            return rightsService.selectRightsByList();
        }else if (type.equals("tree")){
            return rightsService.selectRightByTreeQuicker();
        }else {
            ResponseResult result =new ResponseResult();
            result.setBADREQUEST();
            return result;
        }
    }
    @GetMapping("menus")
    public ResponseResult selectMenus(){
        return rightsService.selectRightByTreeQuicker();
    }

}
